/**
 * 
 */
package com.taobao.wolfwolf.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Tux
 *
 * ����ʱ��: 2011-5-5 ����07:43:00
 */
public class JSONArray {
	List<Object> list = new ArrayList<Object>();
	
	public JSONArray() {
	}
	
	public boolean isEmpty() {
		return list.isEmpty();
	}
	
	public void add(Object o) {
		list.add(o);
	}
	
	public String toJSONString() {
		StringBuffer buffer = new StringBuffer();
		
		buffer.append("[");
		for(Object o : list) {
			if(o instanceof JSONObject) {
				buffer.append(((JSONObject) o).toJSONString() + ",");
			} else if(o instanceof Integer || o instanceof Float || o instanceof Double) {
				buffer.append("{" + o + "},");
			} else if(o instanceof String)
				buffer.append("{\"" + o + "\"},");
		}
		buffer.append("]");
		buffer.deleteCharAt(buffer.length() - 2);
		
		return buffer.toString();
	}
}
